package com.fjp.heartguard.ui.message

import android.os.Bundle
import com.fjp.heartguard.app.base.BaseActivity
import com.fjp.heartguard.app.util.DateTimeUtil
import com.fjp.heartguard.databinding.ActivityAssessmentTimeoutDetailBinding
import com.fjp.heartguard.viewmodel.AssessmentTimeoutDetailViewModel
import me.hgj.jetpackmvvm.ext.parseState

class AssessmentTimeoutDetailActivity : BaseActivity<AssessmentTimeoutDetailViewModel, ActivityAssessmentTimeoutDetailBinding>() {
    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.viewModel = mViewModel
        mViewModel.title.set("消息详情")
        mViewModel.getOverdueOlders()
    }


    override fun createObserver() {
        super.createObserver()

        mViewModel.overdueOlders.observe(this) {
            var content = ""

            parseState(it, {
                it.forEach {
                    content += "${it.name}      ${it.mobile}    已逾期${it.yq_days}天\n"
                }
                mDatabind.titleTv.text = "本月还有${it.size}位老人尚未评估，请尽快安排"
                mDatabind.timeTv.text = DateTimeUtil.formatDate(System.currentTimeMillis(), DateTimeUtil.DATE_PATTERN_SS)
            })
            mDatabind.contentTv.text = content
        }
    }
}